package com.tq68.weixin.intercept;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

public class UserIntercept implements Interceptor {

	public void intercept(Invocation inv) {
		//当方法是检查登陆时，不拦截
		if ((inv.getControllerKey().equals("/sellerlogin") && inv.getMethodName().equals("index"))
				||inv.getControllerKey().equals("/msg")) {
			inv.invoke();
			return;
		}else if((inv.getControllerKey().equals("/sellerlogin") && inv.getMethodName().equals("login"))
				|| (inv.getControllerKey().equals("/sellerlogin") && inv.getMethodName().equals("loginSuccess"))
				|| (inv.getControllerKey().equals("/login"))){
			
		}else if(inv.getController().getSessionAttr("sellervo")==null && inv.getController().getSessionAttr("uservo")==null){
			inv.getController().redirect("/sellerlogin");
			return;
		}
		inv.invoke();
		inv.getController().setAttr("uservo", inv.getController().getSessionAttr("uservo"));
		inv.getController().setAttr("sellervo", inv.getController().getSessionAttr("sellervo"));
	}
}
